#ifndef DTTRACK_H
#define DTTRACK_H

#include "../abstract/abstractdata.h"
#include <QString>
#include <QTime>

class DtAlbum;
class DtGenre;
class DtArtist;

class DtTrack : public AbstractData
{
private:
    QTime time;
    QString lyrics;
    int number;
    int score;
    DtTrack *recovery;
    QString location;
    QList<DtAlbum *> album;
    QList<DtArtist *> artist;
    QList<DtGenre *> genre;

public:
    enum {
        Id,
        Name,
        Time,
        Lyrics,
        Number,
        Score,
        Recovery,
        Heart,
        Play,
        Add,
        Location,
        Album,
        Artist,
        Genre,

        NbAttr
    };
    DtTrack();
    DtTrack(const QString &location, const QString & name = QString::null,
            const int number = -1, const int id = -1,
            DtAlbum * album = NULL,
            DtArtist * artist = NULL,
            DtGenre * genre = NULL, const QTime & time = QTime(),
            const QString & lyrics = QString::null, const int score = -1,
            DtTrack * recovery = NULL, const bool heart = false);
    DtTrack(const DtTrack & track);
    virtual ~DtTrack();
    /**
     * @brief operator << is use for the debbugging with Qt. See the Qt Doc to
     *find more help on this function
     * @param dbg the stream of debugging
     * @param artist the artist to show
     * @return
     */
    friend QDebug operator<<(QDebug dbg, const DtTrack &track);

    /*!
     * \brief Lorsque l'utilisateur clique sur une colonne une action est lancée
     *
     * Méthode de gestion d'action sur le tableau. Elle permet d'effectuer
     *l'action adéquate pour la case
     * \param section : Le numéro de la colonne
     */
    void clicked(const int section);

    QList<DtAlbum *> &getAlbums();
    QList<DtArtist *> &getArtists();
    QList<DtGenre *> &getGenres();

    QTime getTime() const;
    void setTime(const QTime &time);
    QString getLyrics() const;
    void setLyrics(const QString &lyrics);
    int getNumber() const;
    void setNumber(const int number);
    int getScore() const;
    void setScore(const int score);
    DtTrack *getRecovery() const;
    void setRecovery(DtTrack *recovery);
    QString getLocation() const;
    void setLocation(const QString &location);
    DtAlbum *getAlbum() const;
    void setAlbum(DtAlbum *album);
    DtArtist *getArtist() const;
    void setArtist(DtArtist *artist);
    DtGenre *getGenre() const;
    void setGenre(DtGenre *genre);
};

/**
 * @brief operator == is use for the QSet container.
 * @param track1
 * @param track2
 * @return
 */
inline bool operator==(const DtTrack &track1, const DtTrack &track2)
{
    return (track1.getLocation() == track2.getLocation());
}

/**
 * @brief qHash is use for the QSet container too
 * @param track
 * @return
 */
inline uint qHash(const DtTrack & track)
{
    return qHash(track.getLocation());
}

#endif // DTTRACK_H
